#include "aux.h"

char* readKernel(void);

char* readKernel(void)
{
    size_t source_length;
    FILE* fp = fopen("kernel.cl", "r");
    if (fp==NULL){
        printf("Cannot open kernel.cl\n");
    } else {
        printf("kernel.cl opened\n");
    }

    fseek(fp, 0, SEEK_END);
    source_length = (size_t) ftell(fp);
    if (source_length==0){
        printf("kernel.cl is empty\n");
    } else {
        printf("kernel.cl length: %zu bytes\n", source_length);
    }

    char* source = (char*) calloc(source_length + 1, 1);
    if (source==0){
        printf("Memory allocation failed");
    }
    fseek(fp, 0, SEEK_SET);
    fread(source, 1, source_length, fp);
    printf("kernel.cl read\n");

    return source;
}
